Image processing device, electronic camera, and image processing program

ABSTRACT

An image processing device of the present invention includes a color-gamut determining part, a color-space determining part, and a color-space conversion part. The color-gamut determining part determines a color gamut as a range of color distribution from input image data. The color-space determining part determines a color space substantially covering the color gamut determined by the color-gamut determining part. The color-space conversion part converts the input image data into such image data that is rendered in the determined color space. The colors of the subject can thus be reproduced accurately from the converted image data.

CROSS REFERENCE TO RELATED APPLICATION

[0001] This application is based upon and claims the benefit of priorityfrom Japanese Patent Application No. 2002-365476, filed on Dec. 17,2002, the entire contents of which are incorporated herein by reference.

BACKGROUND OF THE INVENTION

[0002] 1. Field of the Invention

[0003] The invention relates to an image processing device forconverting color spaces of image data. The invention also relates to anelectronic camera on which the image processing device is mounted, andan image processing program.

[0004] 2. Description of the Related Art

[0005] In general, image data created by a color image processing devicesuch as an electronic camera, a digital video camera, and a scanner isinitially subjected to processings including color conversion, toneprocessing, and contour enhancement processing. The image data is thenrecorded on a recording medium such as a memory and a magnetic tape, ortransmitted to external equipment via communication media. The recordedimage data is reproduced, for example, as a photograph by a developingmachine, a printer, etc. The transmitted image data is reproduced on amonitor as a moving image or a still image, for example.

[0006] In order to reproduce the colors of the recorded or transmittedimage data accurately, the image-capturing side and the reproductionside need to process the image data by using the same standard. For thispurpose, various types of standards (color spaces) for expressing colorshave been established. Then, the color coordinates of the threeprincipal colors (R, G, and B) differ from one standard to another.

[0007]FIG. 1 shows an xy chromaticity diagram showing NTSC color spaceand sRGB color space. Note that the horseshoe shaped area is a colorrange that humans are perceptible of (hereinafter, to be referred to asvisible region). The image-capturing side can encode only colors insidethe respective triangles with the coordinates of R, G, and B as thevertexes in the color space it uses. Similarly, the reproduction sidecan reproduce only colors inside the respective triangles with thecoordinates of R, G, and B as the vertexes in the color space it uses.In the present invention, the range of colors that can be thus expressedin a color space, as well as the range of color distribution of asubject, shall be referred to as color gamut. As is evident from FIG. 1,the ranges of colors that can be expressed in NTSC color space and sRGBcolor space are smaller than the visible region. This also holds formost other color spaces (including CIE RGB and Adobe RGB (TM)).

[0008] When the color space determined according to the color filters ofan image sensor does not cover the color gamut of a subject, the colorsof the subject is not reproducible accurately from the image datacreated by this image-capturing system. Additionally, even with theimage-capturing system having a color space that covers the color gamutof a subject, it is not possible to reproduce the colors of the subjectwith accuracy if the image data created by this image-capturing systemis converted into such image data that it is rendered in a color spacenot covering the color gamut of the subject.

[0009] In view of this, Japanese Unexamined Patent ApplicationPublication No. 2002-109523 has proposed a method of establishing a newcolor space capable of expressing all colors and capturing an image inthis color space. This new color space differs from the known colorspaces in the coordinates of the three principal colors. The image databased on the new three principal colors is thus converted into imagedata based on known three principal colors before output to an existingimage output apparatus.

[0010] In general, image data yet to be compressed consists of pixelswhose colors are encoded in a predetermined number of bits each (forexample, 8 bits for each of the three principal colors). If encoded in alarger color space, the captured image data is thus expected to begreater in color difference per tone. Once the image data is encoded inwider tones, it is impossible to make the tones finer in subsequentprocessings. A greater color difference per tone results in unclearreproduced images and making it difficult to process the image data.

[0011] Besides, it is troublesome and difficult for the user to selectan appropriate color space depending on the subject because he or she isrequired to have expertise on NTSC, sRGB, and other color spaces.

SUMMARY OF THE INVENTION

[0012] It is an object of the present invention to provide a techniquefor reproducing the color gamut of a subject with good chroma and toneswithout the necessity for the user to select a color space.

[0013] An image processing device of the present invention includes acolor-gamut determining part, a color-space determining part, and acolor-space conversion part. The color-gamut determining part determinesa color gamut as a range of color distribution from input image data.The color-space determining part determines a color space substantiallycontaining the color gamut determined by the color-gamut determiningpart. The color-space conversion part converts the input image data intoimage data which is rendered in the determined color space. It may beexpected that the colors of the subject are accurately reproducible fromthe converted image data. Incidentally, the color-space conversion partherein will sometimes be referred to as color correcting part.

[0014] According to one of the aspects of the image processing device ofthe present invention, the color-gamut determining part divides theinput image data into a plurality of image regions, calculates a hue anda chroma for each of the image regions, and determines a maximum chromafor each of the hues calculated. The color-space determining partselects a smallest color space from color spaces each having a maximumchroma equal to or higher than that of the input image data in all ofthe hues calculated by the color-gamut determining part.

[0015] This calculation function of the color-gamut determining partwill sometimes be referred to as evaluation value calculation part, andeach of the divided image regions will sometimes be referred to as asmall region. Moreover, in this aspect of the image processing device,the above-described “a color space substantially containing the colorgamut” corresponds to a color space having a maximum chroma equal to orhigher than that of the input image data in all of the hues calculated,for example. A small color space signifies that an average of themaximum chroma determined for each of the hues is small, for example.

[0016] According to another aspect of the image processing device of thepresent invention, the color-gamut determining part maps the input imagedata onto a chromaticity diagram. Then, the color-space determining partselects a smallest color space from color spaces each containing apredetermined percentage or more of the color gamut of the input imagedata on the chromaticity diagram. Here, the color spaces each containinga predetermined percentage or more of the color gamut correspond to theabove-mentioned color space substantially containing the color gamut.Specifically, for example, it corresponds to the color space containingthe color gamut of the subject at or over a predetermined area ratio onthe chromaticity diagram. The small color space here refers to a colorspace of a small size on the chromaticity diagram, for example.

[0017] According to another aspect of the image processing device of thepresent invention, the color-space conversion part transmits informationon the color space determined by the color-space determining part to adestination to which the converted image data is output. Here, theinformation on the color space refers to several bits of digital dataindicating the name of the color space, for example.

[0018] An electronic camera of the present invention includes animage-capturing part and an image processing device. The image-capturingpart captures an optical image formed with a shooting lens to createimage data. Incidentally, this image-capturing part refers to a parthaving a release button, a CPU, a focal-plane shutter, a CCD, and asignal processing part, for example.

[0019] The image processing device includes a color-gamut determiningpart, a color-space determining part, and a color-space conversion part.The color-gamut determining part determines a color gamut as a range ofcolor distribution from image data obtained from the image-capturingpart. The color-space determining part determines a color spacesubstantially containing the color gamut determined by the color-gamutdetermining part. The color-space conversion part converts the inputimage data into image data which is rendered in the determined colorspace.

[0020] An image processing program of the present invention causes acomputer to function as a color-gamut determining part, a color-spacedetermining part, and a color-space conversion part. Here, thecolor-gamut determining part has a function of determining a color gamutas a range of color distribution from input image data. The color-spacedetermining part has a function of determining a color spacesubstantially containing the color gamut determined by the color-gamutdetermining part. The color-space conversion part has a function ofconverting the input image data into image data which is rendered in thedetermined color space.

[0021] According to one of the aspects of the image processing programof the present invention, the color-gamut determining part divides theinput image data into a plurality of image regions, calculates a hue anda chroma for each of the image regions, and determines a maximum chromafor each of the calculated hues. The color-space determining partselects a smallest color space from color spaces each having a maximumchroma equal to or higher than that of the input image data in all ofthe hues calculated by the color-gamut determining part.

[0022] According to another aspect of the image processing program ofthe present invention, the color-gamut determining part maps the inputimage data onto a chromaticity diagram. Then, the color-spacedetermining part selects a smallest color space from color spacescontaining a predetermined percentage or more of the color gamut of theinput image data on the chromaticity diagram.

[0023] According to another aspect of the image processing program ofthe present invention, the color-space conversion part transmitsinformation on the color space determined by the color-space determiningpart to a destination to which the image data converted is output.

BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The nature, principle, and utility of the invention will becomemore apparent from the following detailed description when read inconjunction with the accompanying drawings in which like parts aredesignated by identical reference numbers, in which

[0025]FIG. 1 is an xy chromaticity diagram showing NTSC color space andsRGB color space;

[0026]FIG. 2 is a block diagram of an electronic camera on which animage processing device according to a first embodiment of the presentinvention is mounted;

[0027]FIG. 3 is a flowchart showing the operation of the imageprocessing device of the first embodiment;

[0028]FIG. 4 is an explanatory diagram showing an example of a huecalculation table to be used by the color-gamut determining part of FIG.2;

[0029]FIG. 5 is an explanatory diagram showing an example of a chromacalculation table to be used by the color-gamut determining part of FIG.2;

[0030]FIG. 6 shows a way of comparing the color gamut of a subject withthe color gamuts of respective color spaces stored in advance by thecolor-space determining part of FIG. 2;

[0031]FIG. 7 is a flowchart showing the operation of the imageprocessing device of a second embodiment;

[0032]FIG. 8 is a block diagram of an electronic camera on which theimage processing device according to a third embodiment of the presentinvention is mounted;

[0033]FIG. 9 is a flowchart showing the operation of the imageprocessing device of the third embodiment; and

[0034] FIGS. 10(A), (B) are diagrams for illustrating the imageprocessing device's processings of determining the color gamut of thesubject and comparing it with the color gamuts of respective colorspaces stored in advance according to the third embodiment.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0035] Hereinafter, embodiments of the present invention will bedescribed with reference to the drawings.

[0036] <First Embodiment>

[0037]FIG. 2 shows a first embodiment of the present invention. In thediagram, a photographing device 10A is made up of an electronic camera12A of the present invention, equipped with a shooting lens 14 and arecording medium 16. The shooting lens 14 consists of a lens group 20and an aperture (diaphragm) 22.

[0038] The electronic camera 12A includes a release button 30, a CPU 32,a memory 34, a focal-plane shutter 36, a CCD 38, a signal processingpart 40, a white balance adjusting part 42, a color interpolationprocessing part 44 (hereinafter, to be referred to as Debayer processingpart 44 because it performs Debayer processing on a Bayer array as a wayof example in the present embodiment), an image processing device 50 ofthe present invention, a gamma correction part 52, a contour enhancingpart 54, an image-data compressing part 56, and a recording part 58.

[0039] The CPU 32 controls each part of the electronic camera 12A.

[0040] On its light receiving plane, the CCD 38 has color filters FR,FG, and FB (not shown) transmitting the three principal colors, red,green, and blue (hereinafter, abbreviated as R, G, and B), respectively.Each pixel of the CCD 38 thus converts only the intensity of awavelength corresponding to one of R, G, and B into a stored charge.

[0041] The signal processing part 40 applies clamp processing,sensitivity correction processing, analog-to-digital conversion, and thelike to the pixel outputs of the CCD 38 to create image data. Note thatthe present embodiment describes an example of the analog-to-digitalconversion in which each of the R, G, and B pixel outputs is encoded inunit of 12 bits. The signal processing part 40 inputs the created imagedata to the image processing device 50 and the white balance adjustingpart 42.

[0042] The white balance adjusting part 42 applies white balanceprocessing to the image data by using gains for white balance processingto be described later as parameters. The white balance adjusting part 42inputs the processed image data to the Debayer processing part 44.

[0043] The Debayer processing part 44 applies Debayer processing to theimage data. This provides each pixel with 12 bits of digital data on allthe three principal colors. The Debayer processing part 44 inputs theDebayer-processed image data to the image processing device 50.

[0044] The image processing device 50 includes an evaluation valuecalculation part 62, a WB gain calculating part 64 (WB is short forwhite balance), a color-gamut determining part 66, a color-spacedetermining part 68, and a color correcting part 70. The imageprocessing device 50 converts the image data based on the color space ofthe three principal colors of the color filters on the CCD 38 into imagedata based on an appropriate color space, and inputs the same to thegamma correction part 52 (details will be given later).

[0045] The gamma correction part 52 applies gamma correction to theinput image data, and then outputs the resultant to the contourenhancing part 54. Here, for example, the gamma correction part 52reduces the tones of pre-converted image data in which every pixel has12 bits for each of the three principal colors so that every pixel has 8bits for each of the three principal colors in the processed image data.The contour enhancing part 54 applies image sharpening processing to theimage data, and inputs the resultant to the image-data compressing part56.

[0046] The image-data compressing part 56 applies, for example, JPEGconversion to the image data for compression. The recording part 58receives, from the image processing device 50, color-space informationindicating in what color space the image data input from the image-datacompressing part 56 is rendered. The recording part 58 records the imagedata onto the recording medium 16 along with this color-spaceinformation.

[0047]FIG. 3 is a flowchart showing the operation of the imageprocessing device 50 described above. FIG. 4 is an example of a huecalculation table for use in the processing of the color-gamutdetermining part 66. FIG. 5 is an example of a chroma calculation tablefor use in the processing of the color-gamut determining part 66. FIG. 6is an explanatory diagram showing a way of comparing the color gamut ofa subject with the color gamuts of respective color spaces stored inadvance by the color-space determining part 68. Hereinafter, theoperation of the image processing device 50 will be described in theorder of step numbers shown in FIG. 3, with reference to FIGS. 4 to 6.It should be appreciated that arithmetic expressions and numeric valuesto be seen below are given by way of example for the purpose ofreference, not limitations on the present invention.

[0048] [Step S1]

[0049] According to instructions from the CPU 32, the CCD 38 convertslight received from a subject through the shooting lens 14 into electriccharges for storage. According to instructions from the CPU 32, thesignal processing part 40 reads the stored charges from the CCD 38 tocreate image data. For example, the image data consists of 1000vertical×1500 horizontal, i.e., 1.5 million pixels. The image processingpart 40 inputs the created image data to the evaluation valuecalculation part 62. Note that this image data is not subjected toDebayer processing yet, and it consists of pixels each encoded in 12bits for one of the three principal colors R, G, and B.

[0050] [Step S2]

[0051] The evaluation value calculation part 62 divides the image datainto 8 vertical×12 horizontal, i.e., 96 regions. Hereinafter, each ofthe divided regions will be referred to as small region. For each smallregion, the evaluation value calculation part 62 calculates averagesRav, Gav, and Bav of the values (expressed by digital data) thatindicate the intensities of the three principal colors R, G, and B,respectively. Specifically, the average Rav is determined by averagingthe digital data on all the pixels corresponding to R in a small region.The same operations are performed for G and B to calculate Gav and Bav.The evaluation value calculation part 62 transmits Rav, Gav, and Bav tothe color-gamut determining part 66 and the WB gain calculating part 64.The WB gain calculating part 64 determines gains for white balanceprocessing based on Rav, Gav, and Bav, and transmits the same to thewhite balance adjusting part 42.

[0052] [Step S3]

[0053] For each small region, the color-gamut determining part 66determines a representative hue and a representative chroma through thefollowing procedure. Initially, R/B and B/G defined by the followingequations are determined from Rav, Gav, and Bav calculated at step S2:

R/G=Rav÷Gav×100  (1)

B/G=Bav÷Gav×100  (2)

[0054] Next, in the hue calculation table shown in FIG. 4, the datacorresponding to R/G and B/G determined is considered as arepresentative hue of the small region. In addition, in the chromacalculation table shown in FIG. 5, the data corresponding to R/G and B/Gdetermined is considered as the representative chroma of the smallregion. Note that the hue calculation table mentioned above has valuesof 0 to 255 (8 bits) on both the ordinate (B/G) and abscissa (R/G),whereas FIG. 4 shows only some representative values. The same holds forthe chroma calculation table of FIG. 5. The color-gamut determining part66 considers B/G or R/G exceeding 255 in value as 255.

[0055] [Step S4]

[0056] The color-gamut determining part 66 classifies all the smallregions according to the representative hues. Next, a small regionhaving a maximum representative chroma is determined from small regionshaving a same value of representative hue. The representative chroma ofthe determined small region shall be the maximum chroma for therepresentative hue of this small region. In this way, the color-gamutdetermining part 66 determines the maximum chroma for each of therepresentative hues obtained at step S3. The color-gamut determiningpart 66 transmits the maximum chromas for the respective representativehues to the color-space determining part 68 as the color gamut of thesubject.

[0057] [Step S5]

[0058] As shown in FIG. 6, the color-space determining part 68 stores inadvance a relationship between representative values of hue (0, 1, . . ., 15) and maximum chromas in several color spaces (such as CIE-RGB colorspace, NTSC color space, and sRGB color space). For reference, FIG. 6also shows an example of the color gamut of a subject.

[0059] Then, the color-space determining part 68 compares the colorgamut of each of the color spaces and that of the subject to select asmallest color space out of the color spaces that include the colorgamut of the subject. Specifically, the color-space determining part 68selects a color space having a smallest average of the maximum chromafrom the color spaces each having a maximum chroma equal to or higherthan that of the color gamut of the subject in all the representativehues.

[0060]FIG. 6 shows an example in which NTSC color space is selected asthe optimum color space. The color-space determining part 68 transmitsthe information as to which color space has been selected (hereinafter,referred to as color-space information) to the color correcting part 70and the recording part 58. Here, the transmission is effected, forexample, by setting four bits of digital data for indicating the namesof the respective color spaces in advance and transmitting the digitaldata.

[0061] [Step S6]

[0062] The color correcting part 70 receives the image data transmittedfrom the Debayer processing part 44. Incidentally, this image data isrendered in the color space determined by the three principal colors ofthe color filters on the CCD 38. The color correcting part 70 stores inadvance therein matrix factors Ma, Mb, Mc, Md, Me, Mf, Mg, Mh, and Mifor each color space which are used for converting the transmitted imagedata into such image data that it is rendered in CIE-RGB color space,NTSC color space, sRGB color space, and the like. Note that the matrixfactors Ma to Mi are intended not only for color-space conversion butalso for color correction ascribable to the fact that neither theshooting lens 14 nor the CCD 38 has ideal spectral characteristics.

[0063] The color correcting part 70 selects matrix factors Ma to Micorresponding to the color space selected at step S5. The colorcorrecting part 70 performs color-space conversion on the transmittedimage data by using the following three equations (collectively referredto as Equation (3)):

Rm=Rc×Ma+Gc×Mb+Bc×Mc

Gm=Rc×Md+Gc×Me+Bc×Mf

Bm=Rc×Mg+Gc×Mh+Bc×Mi  (3)

[0064] In the foregoing equation, Rc, Gc, and Bc are pieces of digitaldata corresponding to the three principal colors of the image datatransmitted from the Debayer processing part 44. Rm, Gm, and Bm arepieces of digital data corresponding to the three principal colors ofthe converted image data. The color correcting part 70 then transmitsthe converted image data to the gamma correction part 52.

[0065] The description so far has been made on the operation of theimage processing device 50 of the present embodiment. The convertedimage data which is rendered in an appropriate color space in this wayis subjected to the above-mentioned processings in the gamma correctionpart 52, the contour enhancing part 54, and the image-data compressingpart 56 before recorded onto the recording medium 16 along with thecolor-space information.

[0066] As described above, the image processing device 50 of the presentembodiment uses table data shown in FIGS. 4 and 5 to determinerepresentative hues and representative chromas in the respective smallregions of the image data. Then, with the maximum chromas for therepresentative hues determined as evaluation reference, the imageprocessing device 50 determines the color gamut of the subject that isexpressed by the image data based on the color space of the colorfilters on the CCD 38. Consequently, the color gamut of the subject canbe obtained efficiently with a fewer times of operations. This resultsin simplifying the configuration of the image processing device 50.Moreover, as shown in FIG. 6, whether or not the individual color spacescover the color gamut of the subject can be determined easily by simplycomparing the maximum chromas for the representative hues.

[0067] Then, the smallest color space is selected from among the colorspaces that cover the color gamut of the subject. More specifically, itis possible to automatically select a color space that covers the colorgamut of the subject and has a minimum color difference per tone, forthe image data obtained immediately after photographing and consistingof pixels whose colors are encoded in a predetermined number of bits.This holds true even if the image data is reduced in the number of bitsby subsequent processings (gamma correction part 52).

[0068] In addition, the image data is converted into such image datathat it is rendered in an appropriate color space selected, andthereafter it is recorded onto the recording medium 16 along with thiscolor-space information (step S6). Consequently, reproducing the imagedata based on the color-space information enables the colors of thecaptured subject to be reproduced accurately in favorable tones.

[0069] Moreover, the user need not have expertise on color spaces forselecting a color space so that he or she can focus on takingphotographs. Also, allowing the image processing device 50 to select anappropriate color space depending on the color gamut of the subjectmakes it possible to create better pictures. As a result, the user'susability improves greatly.

[0070] The evaluation value calculation part 62 calculates the averagesRav, Gav, and Bav of R, G, and B for each small region, and transmitsthe calculation results to the color-gamut determining part 66 and theWB gain calculating part 64. It is therefore possible to use thecalculation results of the evaluation value calculation part 62 both forthe processing of determining the color gamut of the subject and for thewhite balance processing. This results in simplifying the configurationof the image processings of the electronic camera 12A.

[0071] <Second Embodiment>

[0072] Next, description will be made on a second embodiment of thepresent invention. The present embodiment differs from the firstembodiment only in that the calculations of the WB gain calculating partare also used for the processing in the color-gamut determining part(corresponding to the part shown by the broken-lined arrow in FIG. 2).Thus, in the present embodiment, the image processing device shall bedesignated distinctively as 50 b, the WB gain calculating part as 64 b,and the color-gamut determining part as 66 b while the block diagram isomitted.

[0073]FIG. 7 is a flowchart showing the operation of the imageprocessing device 50 b of the present embodiment. Hereinafter, theoperation of the image processing device 50 b will be described in theorder of step numbers shown in FIG. 7. It should be appreciated thatarithmetic expressions and numeric values to be seen below are given byway of example for the purpose of reference, not limitations on thepresent invention.

[0074] [Step S11]

[0075] As in step S1 of the first embodiment, image data is created andinput to the evaluation value calculation part 62.

[0076] [Step S12]

[0077] As in step S2 of the first embodiment, the evaluation valuecalculation part 62 divides the image data into a plurality of smallregions, and determines the averages Rav, Gav, and Bav of R, G, and B ineach small region. The evaluation value calculation part 62 transmitsRav, Gav, and Bav to the color-gamut determining part 66 b and the WBgain calculating part 64 b. The WB gain calculating part 64 b determinesgains Wr, Wg, and Wb for white balance processing based on Rav, Gav, andBav, and transmits the same to the white balance adjusting part 42 andthe color-gamut determining part 66 b.

[0078] [Step S13]

[0079] Based on the gains Wr, Wg, and Wb for white balance processing,the color-gamut determining part 66 b converts Rav, Gav, and Bav intovalues Rav′, Gav′, and Bav′ that are adjusted in white balance. Thisconversion method is the same as what the white balance adjusting part42 applies to image data, being expressed by, e.g., the following threeequations (collectively referred to as Equation (4)):

Rav′=Rav×Wr

Gav′=Gav×Wg

Bav′=Bav×Wb  (4)

[0080] As in the first embodiment, the color-gamut determining part 66 bdetermines R/G and B/G in each small region by the following equations,and determines a representative hue and a representative chroma in eachsmall region by using the hue calculation table of FIG. 4 and the chromacalculation table of FIG. 5.

R/G=Rav′÷Gav′×100  (5)

B/G=Bav′÷Gav′×100  (6)

[0081] The processing of the subsequent steps S14, S15, and S16 are thesame as that of steps S4, S5, and S6 of the first embodiment,respectively. Description thereof will thus be omitted.

[0082] As above, the second embodiment can provide the same effects asthose of the foregoing first embodiment. Besides, in the presentembodiment, the color-gamut determining part 66 b converts the averagesRav, Gav, and Bav of R, G, and B determined for each small region intothe values Rav′, Gav′, and Bav′ that are adjusted in white balance, andthen determines representative hues and representative chromas in therespective small regions. That is, the processing of the color-gamutdetermining part 66 b is equivalent to predicting how the image data isconverted by the white balance adjusting part 42 and determining thecolor gamut of the subject to be expressed by the image data adjusted inwhite balance. As a result, it is possible to determine the color gamutof the subject more accurately regardless of the color temperature ofthe light source that has illuminated the subject at the time ofshooting.

[0083] <Third Embodiment>

[0084]FIG. 8 shows a third embodiment of the present invention. The sameparts as those of the first embodiment will be designated by identicalreference numbers. Description thereof will be omitted. In the diagram,a photographing device 10C is made up of an electronic camera 12C of thepresent invention, equipped with a shooting lens 14 and a recordingmedium 16.

[0085] The electronic camera 12C includes the release button 30, a CPU32 c, the memory 34, the focal-plane shutter 36, the CCD 38, a signalprocessing part 40, an evaluation value calculation part 62C, the WBgain calculating part 64, a white balance adjusting part 42 c, theDebayer processing part 44, an image processing device 50 c of thepresent invention, the gamma correction part 52, the contour enhancingpart 54, the image-data compressing part 56, and the recording part 58.

[0086] The CPU 32 c controls each part of the electronic camera 12C.

[0087] The evaluation value calculation part 62 c is identical to theevaluation value calculation part 62 of the first embodiment except thatRav, Gav, and Bav calculated for each small region are transmitted onlyto the WB gain calculating part 64.

[0088] The white balance adjusting part 42 c is identical to the whitebalance adjusting part 42 of the first embodiment except that the imagedata adjusted in white balance is also input to the image processingdevice 50 c.

[0089] The image processing device 50 c includes a color-gamutdetermining part 66 c, a color-space determining part 68 c, and a colorcorrecting part 70. The image processing device 50 c converts image databased on the color space of the three principal colors of the colorfilters on the CCD 38 into image data based on an appropriate colorspace, and inputs the same to the gamma correction part 52.

[0090]FIG. 9 is a flowchart showing the operation of the imageprocessing device 50 c described above. FIGS. 10(A), (B) are diagramsfor explaining the processing of determining the color gamut of thesubject and comparing it with the color gamuts of respective colorspaces stored in advance by the image processing device 50 c.Hereinafter, the operation of the image processing device SOc will bedescribed in the order of step numbers shown in FIG. 9, with referenceto FIG. 10.

[0091] [Step S31]

[0092] The signal processing part 40 reads the stored charges from theCCD 38 to create image data, and inputs the same to the evaluation valuecalculation part 62 c and the white balance adjusting part 42 c. As inthe first embodiment, the evaluation value calculation part 62 c dividesthe image data into a plurality of small regions, and determines theaverages Rav, Gav, and Bav of R, G, and B, respectively, in each smallregion. Based on Rav, Gav, and Bav transmitted from the evaluation valuecalculation part 62 c, the WB gain calculating part 64 determines gainsfor white balance processing, and transmits the same to the whitebalance adjusting part 42 c. The white balance adjusting part 42 capplies white balance processing to the image data, and then inputs theresultant to the color-gamut determining part 66 c and the Debayerprocessing part 44.

[0093] [Step S32]

[0094] The color-gamut determining part 66 c maps the input image data(based on the color space determined by the color filters on the CCD 38)onto an xy chromaticity diagram, for example. This mapping is performedin unit of pixels, and table data is created at the same time. Forexample, when the image data covers three pixels that show the colorcorresponding to an x-coordinate of 0.3 and a y-coordinate of 0.4, a rowof table data is expressed as (0.3, 0.4, 3). Such table data is createdon all the coordinates within the visible region.

[0095] [Step S33]

[0096] As shown in FIG. 10(A), the color-gamut determining part 66 cdivides the visible region on the xy chromaticity diagram into N regionsbased on MacAdam ellipse, for example. Hereinafter, each of the Ndivided regions will be referred to as a region of comparable colors.The color-gamut determining part 66 c classifies the individual rows oftable data created at step S32 according to regions of comparablecolors. From among the regions of comparable colors, the color-gamutdetermining part 66 c selects ones that include T or more pixels of themapped image data. In FIG. 10(A), the hatched area is an example of theregions of comparable colors selected here. Note that a single regionincluding T pixels of exactly the same color can also be selected. Thecolor-gamut determining part 66 c informs the color-space determiningpart 68 c of which regions of comparable colors have been selected, asthe color gamut of the subject.

[0097] Incidentally, the value of T mentioned above may be determinedaccording to the value of N and the total number of pixels of the imagedata so that a difference between the actual color gamut of the subjectand the color gamut of the subject determined by the color-gamutdetermining part 66 c falls to or below an acceptable value. The smallerthe value of T, the smaller the difference.

[0098] [Step S34]

[0099] As shown in FIG. 10(B), the color-space determining part 68stores in advance the ranges of distribution of several color spaces(such as NTSC color space and sRGB color space) on the xy chromaticitydiagram. Then, the color-space determining part 68 selects the smallestcolor space out of the color spaces that cover the color gamut of thesubject on the xy chromaticity diagram. Here, a small color space refersto a color area of a small size on the chromaticity diagram. In theexample shown in FIG. 10(B), NTSC color space which covers the hatchedcolor gamut of the subject is selected as the optimum color space. As inthe first embodiment, the color-space determining part 68 transmitscolor-space information on which color space is selected to the colorcorrecting part 70 and the recording part 58.

[0100] If there is no color space that fully covers the color gamut ofthe subject, the smallest color space is selected from among colorspaces that cover the color gamut of the subject on the xy chromaticitydiagram at or above a predetermined area ratio. Here, the predeterminedarea ratio may be set to a value which allows the ratio of the regionnot covered by the selected color space to the color gamut of thesubject determined by the color-gamut determining part 66 c to fall toor below an acceptable value.

[0101] [Step S35]

[0102] As in step S6 of the first embodiment, the color correcting part70 converts the image data transmitted from the Debayer processing part44 into such image data that it is rendered in the color space selectedat step S34. The color correcting part 70 then transmits the convertedimage data to the gamma correction part 52.

[0103] The description so far has been made on the operation of theimage processing device 50 c of the present embodiment.

[0104] As above, the third embodiment can provide the same effects asthose of the first and second embodiments described above.

[0105] <Supplemental Remarks on the Present Invention>

[0106] [1] The foregoing first and second embodiments have dealt withthe cases where the image data is divided into 8 vertical×12 horizontal,i.e., 96 regions. However, the present invention is not limited to suchembodiments. If the color gamut of the subject must be determined moreprecisely, the image data may be divided more finely. To put afunctional limitation, the image data should be divided at such afineness that a difference between the actual color gamut of the subjectand the color gamut of the subject determined by the image processingdevice 50 falls to or below an acceptable value (such as 1%).

[0107] [2] The first and second embodiments have dealt with the caseswhere the evaluation value calculation part 62 calculates, at step S2(step S12), the averages Rav, Gav, and Bav of the three principal colorsR, G, and B for each small region. However, the present invention is notlimited to such embodiments. For example, values that occur with highestfrequency may be determined from the digital data on all the pixelscorresponding to R in the respective small regions. The valuescorresponding to G and B may also be determined similarly. The valuesoccurring with highest frequency can be used in subsequent processinginstead of the averages. Alternatively, maximum values Rmax, Gmax, andBmax in the digital data on all the pixels corresponding to R, G, and Bin the small regions, respectively, may be determined for use instead ofthe averages.

[0108] [3] The third embodiment has dealt with the case where the imagedata is mapped onto the xy chromaticity diagram. However, the presentinvention is not limited to such an embodiment. With human visualsensitivity taken into account, for example, a uv chromaticity diagrammay be used instead of the xy chromaticity diagram.

[0109] [4] The first to third embodiments have dealt with the caseswhere the image processing device (50, 50 b, 50 c) performs color-spaceconversion on the image data before gamma processing. However, thepresent invention is not limited to such embodiments. Following theDebayer processing by the Debayer processing part 44, the gammacorrection part 52 may perform the gamma correction before the imagedata is input to the color correcting part 70.

[0110] [5] The first to third embodiments have dealt with the caseswhere one color space is selected from among a plurality of color spacesstored in advance. However, the present invention is not limited to suchembodiments. For example, it is possible to determine a triangle of asmallest size from triangles covering the color gamut of the subject onthe chromaticity diagram, and establish a new color space having thevertexes of the determined triangle as the color coordinates of thethree principal colors.

[0111] [6] The first to third embodiments have dealt with the caseswhere the image sensor (CCD 38) has a color filter array of principalcolors R, G, and B. However, the present invention is not limited tosuch embodiments. For example, the present invention is also applicableto a color filter array of complementary colors, cyan, magenta, andyellow.

[0112] [7] The first to third embodiments have dealt with the caseswhere the image processing device of the present invention is used foran electronic camera. However, the present invention is not limited tosuch embodiments. For example, the image processing device of thepresent invention may be used for a scanner and the like.

[0113] [8] The processing of steps S1 to S6, steps S11 to S16, or stepsS31 to S35 described above may be coded into an image processingprogram. In this case, the same effects as those of the first to thirdembodiments can be obtained if the image processing program is used aspart of the CPU of an electronic camera, for example.

[0114] The invention is not limited to the above embodiments and variousmodifications may be made without departing from the spirit and scope ofthe invention. Any improvement may be made in part or all of thecomponents.

What is claimed is:
 1. An image processing device comprising: acolor-gamut determining part for determining a color gamut as a range ofcolor distribution from input image data; a color-space determining partfor determining a color space substantially containing the color gamutdetermined by said color-gamut determining part; and a color-spaceconversion part for converting the input image data into image datawhich is rendered in the determined color space.
 2. The image processingdevice according to claim 1, wherein: said color-gamut determining partdivides the input image data into a plurality of image regions andcalculates a hue and a chroma for each of the image regions to determinea maximum chroma for each of hues calculated; and said color-spacedetermining part selects a smallest color space from color spaces eachhaving a maximum chroma equal to or higher than that of the input imagedata in all of the hues calculated by said color-gamut determining part.3. The image processing device according to claim 2, wherein saidcolor-space conversion part transmits information on the color spacedetermined by said color-space determining part to a destination towhich the converted image data is output.
 4. The image processing deviceaccording to claim 1, wherein: said color-gamut determining part mapsthe input image data onto a chromaticity diagram; and said color-spacedetermining part selects a smallest color space from color spaces eachcontaining a predetermined percentage or more of the color gamut of theinput image data on said chromaticity diagram.
 5. The image processingdevice according to claim 4, wherein said color-space conversion parttransmits information on the color space determined by said color-spacedetermining part to a destination to which the converted image data isoutput.
 6. The image processing device according to claim 1, whereinsaid color-space conversion part transmits information on the colorspace determined by said color-space determining part to a destinationto which the converted image data is output.
 7. An electronic cameracomprising: an image-capturing part for capturing an optical imageformed with a shooting lens to create image data; and the imageprocessing device according to claim 1, for determining a range of colordistribution of the created image data to determine a color space, andconverting the created image data into image data which is rendered inthe determined color space.
 8. An image processing program for causing acomputer to function as said color-gamut determining part, saidcolor-space determining part, and said color-space conversion partaccording to claim
 1. 9. An image processing program for causing acomputer to function as said color-gamut determining part, saidcolor-space determining part, and said color-space conversion partaccording to claim
 2. 10. An image processing program for causing acomputer to function as said color-gamut determining part, saidcolor-space determining part, and said color-space conversion partaccording to claim
 3. 11. An image processing program for causing acomputer to function as said color-gamut determining part, saidcolor-space determining part, and said color-space conversion partaccording to claim
 4. 12. An image processing program for causing acomputer to function as said color-gamut determining part, saidcolor-space determining part, and said color-space conversion partaccording to claim
 5. 13. An image processing program for causing acomputer to function as said color-gamut determining part, saidcolor-space determining part, and said color-space conversion partaccording to claim 6.